<?php


namespace app\services;


use app\models\EnergyLogs;

class EnergyLogsService extends Services {

    public function onPaySuccess($event) {
        $type = $event->data['type'];
        $energy_num = $event->data['energy_num'];
        $user_id = $event->data['user_id'];

        $EnergyLogs = new EnergyLogs();
        $EnergyLogs->type = $type;
        $EnergyLogs->num = $energy_num;
        $EnergyLogs->user_id = $user_id;
        $EnergyLogs->ctime = date("Y-m-d H:i:s");
        if (!$EnergyLogs->save()) {
            $event->handled = true;
        }
        return $event->handled;
    }
}